package com.buddy.qreport.template.tpls.pie.basic;

import com.buddy.qreport.template.IReportTemplate;
import com.buddy.qreport.template.ReportDataDimension;
import com.buddy.qreport.template.annotation.ReportTemplate;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@ReportTemplate(type = IReportTemplate.TYPE_NAME_PIE)
public class BasicPieReportTemplate implements IReportTemplate {

    private String demoJs;

    private String optionJs;

    private List<ReportDataDimension> reportDataDimensions;

    public BasicPieReportTemplate(){

        reportDataDimensions = new ArrayList<>(2);

        reportDataDimensions.add(new ReportDataDimension("图例","legend",false));
        reportDataDimensions.add(new ReportDataDimension("数据","data",false));

        demoJs =  new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("template/pie/basic/demo.js")))
                .lines().parallel().collect(Collectors.joining("\n"));

        optionJs =  new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("template/pie/basic/template.js")))
                .lines().parallel().collect(Collectors.joining("\n"));


    }

    @Override
    public String getName() {
        return "basic_pie";
    }

    @Override
    public String getDescription() {
        return "基础饼图";
    }

    @Override
    public String getDemoJs() {
        return demoJs;
    }

    @Override
    public String getTemplateOptionJs() {
        return optionJs;
    }

    @Override
    public List<ReportDataDimension> getDataDimensions() {

        return reportDataDimensions;
    }

}
